<template>
    <div>
        <div style="margin-bottom: 10px;width: 200px;">
            <Input search   placeholder="根据编号或姓名搜索..." @on-search="getDataByParameter"/>
        </div>

        <Table border :columns="columns" :data="records"></Table>

        <div style="margin: 10px;overflow: hidden">
            <div style="float: right;">
                <Page :total="total" :current="current" show-sizer show-total @on-change="getPage"
                      @on-page-size-change="getPageSize"/>
            </div>
        </div>
    </div>
</template>

<script>
    import vueEvent from '../../../../public/js/vueEvent.js'
    export default {
        name: "UserList",
        data() {
            return {
                current: 1,
                size: 10,
                total: 0,
                parameter:'',
                columns: [
                    {
                        title: '用户编号',
                        key: 'userId',
                        align: 'center',
                    },
                    {
                        title: '姓名',
                        key: 'userName',
                        align: 'center',
                    },
                    {
                        title: '性别',
                        key: 'sex',
                        align: 'center',
                    },
                    {
                        title: '机构名称',
                        key: 'orgName',
                        align: 'center',
                    },
                    {
                        title: '操作',
                        key: 'buyerName',
                        align: 'center',
                        render: (h, obj) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            // this.isModal = true;
                                            //  this.roleId = obj.row.roleId;
                                            //this.$refs.permissionTree.getPermissionData(this.roleId);
                                        }
                                    }

                                }, '查看详情')
                            ])

                        }
                    },
                ],
                records: [],
                isModal: false,
                orgId: '',

            }
        },
        methods: {
            //获取用户列表信息
            getData(orgId) {
                var self = this;
                self.orgId=orgId;
                this.$http.get('/core/users/queryUsersAllByOrgIdParameter', {
                    params: {
                        current: this.current,
                        size: this.size,
                        orgId:orgId,
                        parameter:self.parameter
                    }
                }).then(function (response) {
                    var data = self.common.handleData(response.data, self);
                    self.records = data.records;
                    self.total = data.total;
                    self.current = data.current;
                });
            },
            getDataByParameter(parameter){
                var self = this;
                self.parameter=parameter;
                self.getData(self.orgId);
            },
            //页数
            getPage(value) {
                let self=this;
                this.current = value;
                this.getData(self.orgId);
            },
            //页大小
            getPageSize(value) {
                let self=this;
                this.size = value;
                this.getData(self.orgId);
            },
        },
        mounted() {
            let  self =this;
            let userInfo = self.common.getStorageS("userInfo");
            this.getData(userInfo.orgId);
            vueEvent.$on('getUsersList',function(orgId){
                self.getData(orgId);
            })
        }
    }
</script>

<style scoped>

</style>